home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / Mesa-3.0 / SRC / VB.H < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-22  |  4.3 KB  |  145 lines

  1. /* $Id: vb.h,v 3.4 1998/06/22 03:16:00 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  3.0
  6.  * Copyright (C) 1995-1998  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: vb.h,v $
  26.  * Revision 3.4  1998/06/22 03:16:00  brianp
  27.  * moved VB_MAX definition to config.h
  28.  *
  29.  * Revision 3.3  1998/06/21 02:02:23  brianp
  30.  * added another comment
  31.  *
  32.  * Revision 3.2  1998/02/20 04:53:07  brianp
  33.  * implemented GL_SGIS_multitexture
  34.  *
  35.  * Revision 3.1  1998/02/02 03:09:34  brianp
  36.  * added GL_LIGHT_MODEL_COLOR_CONTROL (separate specular color interpolation)
  37.  *
  38.  * Revision 3.0  1998/01/31 21:06:45  brianp
  39.  * initial rev
  40.  *
  41.  */
  42.  
  43.  
  44. /*
  45.  * OVERVIEW:  The vertices defined between glBegin() and glEnd()
  46.  * are accumulated in the vertex buffer.  When either the
  47.  * vertex buffer becomes filled or glEnd() is called, we must flush
  48.  * the buffer.  That is, we apply the vertex transformations, compute
  49.  * lighting, fog, texture coordinates etc.  Then, we can render the
  50.  * vertices as points, lines or polygons by calling the gl_render_vb()
  51.  * function in render.c
  52.  *
  53.  * When we're outside of a glBegin/glEnd pair the information in this
  54.  * structure is irrelevant.
  55.  */
  56.  
  57.  
  58. #ifndef VB_H
  59. #define VB_H
  60.  
  61.  
  62. #include "types.h"
  63.  
  64.  
  65.  
  66. /*
  67.  * Actual vertex buffer size.
  68.  * Arrays must also accomodate new vertices from clipping.
  69.  */
  70. #define VB_SIZE  (VB_MAX + 2 * (6 + MAX_CLIP_PLANES))
  71.  
  72.  
  73. /* Bit values for VertexSizeMask, below. */
  74. /*#define VERTEX2_BIT  1*/
  75. #define VERTEX3_BIT  2
  76. #define VERTEX4_BIT  4
  77.  
  78.  
  79.  
  80. struct vertex_buffer {
  81.    GLfloat Obj[VB_SIZE][4];    /* Object coords */
  82.    GLfloat Eye[VB_SIZE][4];    /* Eye coords */
  83.    GLfloat Clip[VB_SIZE][4];    /* Clip coords */
  84.    GLfloat Win[VB_SIZE][3];    /* Window coords */
  85.  
  86.    GLfloat Normal[VB_SIZE][3];    /* Normal vectors */
  87.  
  88.    GLubyte Fcolor[VB_SIZE][4];    /* Front colors (RGBA) */
  89.    GLubyte Bcolor[VB_SIZE][4];    /* Back colors (RGBA) */
  90.    GLubyte (*Color)[4];        /* == Fcolor or Bcolor */
  91.  
  92.    GLubyte Fspec[VB_SIZE][4];    /* Front specular color (RGBA) */
  93.    GLubyte Bspec[VB_SIZE][4];    /* Back specular color (RGBA) */
  94.    GLubyte (*Specular)[4];    /* == Fspec or Bspec */
  95.  
  96.    GLuint Findex[VB_SIZE];    /* Front color indexes */
  97.    GLuint Bindex[VB_SIZE];    /* Back color indexes */
  98.    GLuint *Index;        /* == Findex or Bindex */
  99.  
  100.    GLboolean Edgeflag[VB_SIZE];    /* Polygon edge flags */
  101.  
  102.    GLfloat (*TexCoord)[4];    /* Points to one of the MultiTexCoord sets */
  103.    GLfloat MultiTexCoord[MAX_TEX_SETS][VB_SIZE][4];/* Texture coords */
  104.  
  105.    GLubyte ClipMask[VB_SIZE];    /* bitwise-OR of CLIP_* values, below */
  106.    GLubyte ClipOrMask;        /* bitwise-OR of all ClipMask[] values */
  107.    GLubyte ClipAndMask;        /* bitwise-AND of all ClipMask[] values */
  108.  
  109.    GLuint Start;        /* First vertex to process */
  110.    GLuint Count;        /* Number of vertexes in buffer */
  111.    GLuint Free;            /* Next empty position for clipping */
  112.  
  113.    GLuint VertexSizeMask;    /* Bitwise-or of VERTEX[234]_BIT */
  114.    GLuint TexCoordSize;        /* Either 2 or 4 */
  115.    GLboolean MonoColor;        /* Do all vertices have same color? */
  116.    GLboolean MonoNormal;    /* Do all vertices have same normal? */
  117.    GLboolean MonoMaterial;    /* Do all vertices have same material? */
  118.  
  119.    /* to handle glMaterial calls inside glBegin/glEnd: */
  120.    GLuint MaterialMask[VB_SIZE];    /* Which material values to change */
  121.    struct gl_material Material[VB_SIZE][2]; /* New material values */
  122. };
  123.  
  124.  
  125.  
  126. /* Vertex buffer clipping flags */
  127. #define CLIP_RIGHT_BIT   0x01
  128. #define CLIP_LEFT_BIT    0x02
  129. #define CLIP_TOP_BIT     0x04
  130. #define CLIP_BOTTOM_BIT  0x08
  131. #define CLIP_NEAR_BIT    0x10
  132. #define CLIP_FAR_BIT     0x20
  133. #define CLIP_USER_BIT    0x40
  134. #define CLIP_ALL_BITS    0x3f
  135.  
  136. #define CLIP_ALL   1
  137. #define CLIP_NONE  2
  138. #define CLIP_SOME  3
  139.  
  140.  
  141. extern struct vertex_buffer *gl_alloc_vb(void);
  142.  
  143.  
  144. #endif
  145.